import 'package:chewie/chewie.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

//探秘视频
class PlayerDetail extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => PlayerDetailState();
}

VideoPlayerController videoPlayerController;
ChewieController chewieController;

//only static member can be accessed in initializers
final playerWidget = Chewie(
  controller: chewieController,
);

class PlayerDetailState extends State<PlayerDetail> {
  @override
  void initState() {
    super.initState();
    //配置视频地址
    videoPlayerController = VideoPlayerController.network(
        'http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4');
    chewieController = ChewieController(
      videoPlayerController: videoPlayerController,
      aspectRatio: 3 / 2, //宽高比
      autoPlay: true, //自动播放
      looping: true, //循环播放
    );
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return playerWidget;
  }

  @override
  void dispose() {
    videoPlayerController.dispose();
    chewieController.dispose();
    super.dispose();
  }
}
